$(document).on("click", "#bok", function(e) {
    iosOverlay({
        text: "发货成功!",
        duration: 2e3,
        icon: "../../images/check.png"
    });
    return false;
});


function checkAll(){
    if(document.getElementById('check-all').checked==true){
        var inputs = document.getElementsByTagName('input');
        for(var i=0;i<inputs.length;i++)
        {
            if(inputs[i].getAttribute('type')=='checkbox'){
                if (!inputs[i].checked == true){
                    inputs[i].checked = true;
                }
            }
        }
        $("#del").removeClass("btn-default").removeClass("disabled").addClass("btn-danger")
    }else{
        var inputs = document.getElementsByTagName('input');
        for(var i=0;i<inputs.length;i++)
        {
            if(inputs[i].getAttribute('type')=='checkbox'){
                if (inputs[i].checked == true){
                    inputs[i].checked = false;
                }
            }
        }
        $("#del").removeClass("btn-danger").addClass("btn-default").addClass("disabled")
    }
}

$(document).ready(function () {
    countprice();
})

$("input:text").keydown(function (e) {

    if((e.keyCode>=96&&e.keyCode<=105)||(e.keyCode>=48&&e.keyCode<=57)||e.keyCode===8||e.keyCode===9||e.keyCode==18||e.keyCode==115||e.keyCode==123||e.keyCode===16||e.keyCode===67||e.keyCode===116){

    }else {
        tipnum(e)
        this.value="";
    }
});
$("input:text").change(function (e) {
    if(this.value===""){
        tipempty(e)

    }else {
        countprice()
    }
})
function tipnum(e) {
    iosOverlay({
        text: "请输入数字!",
        duration: 2e3,
        icon: "../../images/cross.png"
    });
    return false;
}
function tipempty(e) {
    iosOverlay({
        text: "信息不能为空!",
        duration: 2e3,
        icon: "../../images/cross.png"
    });
    return false;
}

function countprice() {
    var countnum=0;
    var countprice=0;
    var countyf=0;
    $(".count").each(function (index, item) {
        var i=index;
        var countPri=  Number($(item).val());
        var price=Number($(".oneprice")[i].value);
        var yunfei=Number($(".yf")[i].value);
        var count=countPri*price+yunfei;
        $(".countprice")[i].value=count;
        $(".countpriceprev")[i].innerHTML=count;
        countnum+=1;
        countprice+=count;
        countyf+=yunfei;
    })
    $("#countprice").html(countprice);
    $("#count").html(countnum);
    $("#countfy").html(countyf)
}
